package br.com.financeiro.pojo;

// default package
// Generated 10/11/2014 22:21:36 by Hibernate Tools 4.0.0

import static javax.persistence.GenerationType.IDENTITY;

import java.util.HashSet;
import java.util.Set;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;
import javax.persistence.Table;

/**
 * Municipio generated by hbm2java
 */
@Entity
@Table(name = "municipio")
public class Municipio implements java.io.Serializable {
	
	private static final long serialVersionUID = 1L;
	
	private Integer id;
	private Uf uf;
	private String nome;
	private String ibge;
	private Set<Endereco> enderecos = new HashSet<>(0);

	public Municipio() {
	}

	public Municipio(Uf uf, String nome, String ibge) {
		this.uf = uf;
		this.nome = nome;
		this.ibge = ibge;
	}

	public Municipio(Uf uf, String nome, String ibge, Set<Endereco> enderecos) {
		this.uf = uf;
		this.nome = nome;
		this.ibge = ibge;
		this.enderecos = enderecos;
	}

	@Id
	@GeneratedValue(strategy = IDENTITY)
	@Column(name = "id", unique = true, nullable = false)
	public Integer getId() {
		return this.id;
	}

	public void setId(Integer id) {
		this.id = id;
	}

	@ManyToOne(fetch = FetchType.EAGER)
	@JoinColumn(name = "uf_id", nullable = false)
	public Uf getUf() {
		return this.uf;
	}

	public void setUf(Uf uf) {
		this.uf = uf;
	}

	@Column(name = "nome", nullable = false, length = 300)
	public String getNome() {
		return this.nome;
	}

	public void setNome(String nome) {
		this.nome = nome;
	}

	@Column(name = "ibge", nullable = false, length = 45)
	public String getIbge() {
		return this.ibge;
	}

	public void setIbge(String ibge) {
		this.ibge = ibge;
	}

	@OneToMany(fetch = FetchType.EAGER, mappedBy = "municipio")
	public Set<Endereco> getEnderecos() {
		return this.enderecos;
	}

	public void setEnderecos(Set<Endereco> enderecos) {
		this.enderecos = enderecos;
	}
	
	@Override
	public String toString() {	
		return getNome();
	}

}
